package it.irondev.appturismo.dao;

import it.irondev.appturismo.dao.provider.RoutestagesSqlProvider;
import it.irondev.appturismo.entity.Routestages;
import it.irondev.appturismo.entity.RoutestagesExample;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

public interface RoutestagesMapper {
    @SelectProvider(type=RoutestagesSqlProvider.class, method="countByExample")
    int countByExample(RoutestagesExample example);

    @DeleteProvider(type=RoutestagesSqlProvider.class, method="deleteByExample")
    int deleteByExample(RoutestagesExample example);

    @Delete({
        "delete from RouteStages",
        "where idRouteStage = #{idroutestage,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer idroutestage);

    @Insert({
        "insert into RouteStages (idRouteStage, route, ",
        "attraction, attractionType, ",
        "orderPosition)",
        "values (#{idroutestage,jdbcType=INTEGER}, #{route,jdbcType=INTEGER}, ",
        "#{attraction,jdbcType=INTEGER}, #{attractiontype,jdbcType=INTEGER}, ",
        "#{orderposition,jdbcType=INTEGER})"
    })
    int insert(Routestages record);

    @InsertProvider(type=RoutestagesSqlProvider.class, method="insertSelective")
    int insertSelective(Routestages record);

    @SelectProvider(type=RoutestagesSqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="idRouteStage", property="idroutestage", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="route", property="route", jdbcType=JdbcType.INTEGER),
        @Result(column="attraction", property="attraction", jdbcType=JdbcType.INTEGER),
        @Result(column="attractionType", property="attractiontype", jdbcType=JdbcType.INTEGER),
        @Result(column="orderPosition", property="orderposition", jdbcType=JdbcType.INTEGER)
    })
    List<Routestages> selectByExample(RoutestagesExample example);

    @Select({
        "select",
        "idRouteStage, route, attraction, attractionType, orderPosition",
        "from RouteStages",
        "where idRouteStage = #{idroutestage,jdbcType=INTEGER}"
    })
    @Results({
        @Result(column="idRouteStage", property="idroutestage", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="route", property="route", jdbcType=JdbcType.INTEGER),
        @Result(column="attraction", property="attraction", jdbcType=JdbcType.INTEGER),
        @Result(column="attractionType", property="attractiontype", jdbcType=JdbcType.INTEGER),
        @Result(column="orderPosition", property="orderposition", jdbcType=JdbcType.INTEGER)
    })
    Routestages selectByPrimaryKey(Integer idroutestage);
   
    
    @Select({
        "select",
        "idRouteStage, route, attraction, attractionType, orderPosition",
        "from RouteStages",
        "where route = #{idroute,jdbcType=INTEGER}",
        "order by orderposition"
    })
    @Results({
        @Result(column="idRouteStage", property="idroutestage", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="route", property="route", jdbcType=JdbcType.INTEGER),
        @Result(column="attraction", property="attraction", jdbcType=JdbcType.INTEGER),
        @Result(column="attractionType", property="attractiontype", jdbcType=JdbcType.INTEGER),
        @Result(column="orderPosition", property="orderposition", jdbcType=JdbcType.INTEGER)
    })
    Routestages selectByRouteId(Integer idroute);

    @UpdateProvider(type=RoutestagesSqlProvider.class, method="updateByExampleSelective")
    int updateByExampleSelective(@Param("record") Routestages record, @Param("example") RoutestagesExample example);

    @UpdateProvider(type=RoutestagesSqlProvider.class, method="updateByExample")
    int updateByExample(@Param("record") Routestages record, @Param("example") RoutestagesExample example);

    @UpdateProvider(type=RoutestagesSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(Routestages record);

    @Update({
        "update RouteStages",
        "set route = #{route,jdbcType=INTEGER},",
          "attraction = #{attraction,jdbcType=INTEGER},",
          "attractionType = #{attractiontype,jdbcType=INTEGER},",
          "orderPosition = #{orderposition,jdbcType=INTEGER}",
        "where idRouteStage = #{idroutestage,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(Routestages record);
}